package com.school.generator.bean;

import java.util.HashMap;
import java.util.Map;

/**
 * 数据源配置
 *
 * @author sunpx
 */
public class DataSourceConfig {
    /**
     * 链接名称
     */
    private String url;

    /**
     * 用户名
     */
    private String username;

    /**
     * 密码
     */
    private String password;

    /**
     * 驱动
     */
    private String driverClassName;

    /**
     * 数据库名称
     */
    private String database;

    /**
     * 文件模板映射关系
     */
    private Map<String,String> fileMapping;

    {
        fileMapping=new HashMap<>();
        fileMapping.put("bean.java.ftl","bean");
        fileMapping.put("mapper.java.ftl","mapper");
        fileMapping.put("mapper.xml.ftl","mapper");
        fileMapping.put("service.java.ftl","service");
        fileMapping.put("serviceImpl.java.ftl","serviceImpl");
        fileMapping.put("controller.java.ftl","controller");
    }

    private static final DataSourceConfig DATA_SOURCE_CONFIG = new DataSourceConfig();

    private DataSourceConfig() {

    }

    public static DataSourceConfig getDataSourceConfig() {
        return DATA_SOURCE_CONFIG;
    }

    public String getUrl() {
        return url;
    }

    public DataSourceConfig setUrl(String url) {
        this.url = url;
        return DATA_SOURCE_CONFIG;
    }

    public String getUsername() {
        return username;
    }

    public DataSourceConfig setUsername(String username) {
        this.username = username;
        return DATA_SOURCE_CONFIG;
    }

    public String getPassword() {
        return password;
    }

    public DataSourceConfig setPassword(String password) {
        this.password = password;
        return DATA_SOURCE_CONFIG;
    }

    public String getDriverClassName() {
        return driverClassName;
    }

    public DataSourceConfig setDriverClassName(String driverClassName) {
        this.driverClassName = driverClassName;
        return DATA_SOURCE_CONFIG;
    }

    public String getDatabase() {
        return database;
    }

    public DataSourceConfig setDatabase(String database) {
        this.database = database;
        return DATA_SOURCE_CONFIG;
    }

    public Map<String, String> getFileMapping() {
        return fileMapping;
    }

    public DataSourceConfig setFileMapping(Map<String, String> fileMapping) {
        this.fileMapping = fileMapping;
        return DATA_SOURCE_CONFIG;
    }
}
